import { AnyAction } from "@reduxjs/toolkit";
import { produce } from "immer";
import { IAppState } from "./interface";
import types from "../../mutation-types";

// 状态
const appState: IAppState = {
  isCollapse: false,
  themeMode: 'light'
}


const app = (state: IAppState = appState, action: AnyAction) => {
  return produce(state, draftState => {
    switch (action.type) {
      case types.UPDATE_SLIDE_COLLAPSE:
        draftState.isCollapse = action.isCollapse;
        break;
      case types.UPDATE_THEME_MODE:
        draftState.themeMode = action.themeMode;
        break;
      default:
        return draftState;
    }
  });
};

export default app;
